package io.renren.modules.app.service.impl;
import java.util.List;

import io.renren.common.utils.ResultInfo;
import io.renren.modules.app.dao.TZnmhFunctionVersionMenuDao;
import io.renren.modules.app.entity.TZnmhAppVersionRoleMenu;
import io.renren.modules.app.entity.TZnmhFunctionVersionMenu;
import io.renren.modules.app.service.TZnmhAppVersionRoleMenuService;
import io.renren.modules.app.service.TZnmhFunctionVersionMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Transactional
@Service
public class TZnmhFunctionVersionMenuServiceImpl implements TZnmhFunctionVersionMenuService{
    @Autowired
    private TZnmhFunctionVersionMenuDao tZnmhFunctionVersionMenuDao;

    @Resource
    private TZnmhAppVersionRoleMenuService tZnmhAppVersionRoleMenuService;


    @Override
    public long getTZnmhFunctionVersionMenuRowCount(){
        return tZnmhFunctionVersionMenuDao.getTZnmhFunctionVersionMenuRowCount();
    }
    @Override
    public List<TZnmhFunctionVersionMenu> selectTZnmhFunctionVersionMenu(){
        return tZnmhFunctionVersionMenuDao.selectTZnmhFunctionVersionMenu();
    }
    @Override
    public TZnmhFunctionVersionMenu selectTZnmhFunctionVersionMenuByObj(TZnmhFunctionVersionMenu obj){
        return tZnmhFunctionVersionMenuDao.selectTZnmhFunctionVersionMenuByObj(obj);
    }
    @Override
    public TZnmhFunctionVersionMenu selectTZnmhFunctionVersionMenuById(Object id){
        return tZnmhFunctionVersionMenuDao.selectTZnmhFunctionVersionMenuById(id);
    }
    @Override
    public int insertTZnmhFunctionVersionMenu(TZnmhFunctionVersionMenu value){
        return tZnmhFunctionVersionMenuDao.insertTZnmhFunctionVersionMenu(value);
    }
    @Override
    public int insertNonEmptyTZnmhFunctionVersionMenu(TZnmhFunctionVersionMenu value){
        return tZnmhFunctionVersionMenuDao.insertNonEmptyTZnmhFunctionVersionMenu(value);
    }
    @Override
    public int insertTZnmhFunctionVersionMenuByBatch(List<TZnmhFunctionVersionMenu> value){
        return tZnmhFunctionVersionMenuDao.insertTZnmhFunctionVersionMenuByBatch(value);
    }

    @Override
    public int updateTZnmhFunctionVersionMenuById(TZnmhFunctionVersionMenu enti){
        return tZnmhFunctionVersionMenuDao.updateTZnmhFunctionVersionMenuById(enti);
    }
    @Override
    public int updateNonEmptyTZnmhFunctionVersionMenuById(TZnmhFunctionVersionMenu enti){
        return tZnmhFunctionVersionMenuDao.updateNonEmptyTZnmhFunctionVersionMenuById(enti);
    }

    public TZnmhFunctionVersionMenuDao getTZnmhFunctionVersionMenuDao() {
        return this.tZnmhFunctionVersionMenuDao;
    }

    public void setTZnmhFunctionVersionMenuDao(TZnmhFunctionVersionMenuDao tZnmhFunctionVersionMenuDao) {
        this.tZnmhFunctionVersionMenuDao = tZnmhFunctionVersionMenuDao;
    }

    @Override
    public ResultInfo getVersionRoleMenu() {
        List<TZnmhFunctionVersionMenu> list = tZnmhFunctionVersionMenuDao.selectTZnmhFunctionVersionMenu();
        for (TZnmhFunctionVersionMenu tZnmhFunctionVersionMenu :list){
                TZnmhAppVersionRoleMenu newVersionRoleMenu=new TZnmhAppVersionRoleMenu();
                newVersionRoleMenu.setVrmId(tZnmhFunctionVersionMenu.getFvId());
                newVersionRoleMenu.setVrId(tZnmhFunctionVersionMenu.getVersionId());
                newVersionRoleMenu.setMenuId(tZnmhFunctionVersionMenu.getMenuId());
                newVersionRoleMenu.setSequence(tZnmhFunctionVersionMenu.getSequence());
                newVersionRoleMenu.setDeleteFlag("0");
                newVersionRoleMenu.setCreateTime(tZnmhFunctionVersionMenu.getCreateTime());
                newVersionRoleMenu.setCreateUser(tZnmhFunctionVersionMenu.getCreateUser());
                newVersionRoleMenu.setUpdateTime(tZnmhFunctionVersionMenu.getUpdateTime());
                newVersionRoleMenu.setUpdateUser(tZnmhFunctionVersionMenu.getUpdateUser());
                tZnmhAppVersionRoleMenuService.insertNonEmptyTZnmhAppVersionRoleMenu(newVersionRoleMenu);
        }

        return ResultInfo.success(list.size());
    }
}